import cv2 as cv
import numpy as np
import os

BASE_DIR, FILE_NAME = os.path.split(__file__)
path = '../../../../large_data/pic/blurred/swim01.jpg'
IMG_PATH = os.path.join(BASE_DIR, path)

img = cv.imread(IMG_PATH, cv.IMREAD_COLOR)
cv.imshow('ori', img)

print('Press any key on the image window to go on filtering, ESC to exit.')
kernel = np.float32([
    [0, -1, 0],
    [-1, 5, -1],
    [0, -1, 0],
])
cnt = 0
while True:
    cnt += 1
    img = cv.filter2D(img, -1, kernel)
    cv.imshow(f'filtered #{cnt}', img)
    k = cv.waitKey(0) & 0xFF
    if 27 == k:
        print('Exit because user pressed ESC.')
        break
cv.destroyAllWindows()
